package com.adams.dcxt.service;

import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.adams.dcxt.bean.OrderDishes;
import com.adams.dcxt.core.Contants;
import com.adams.dcxt.core.Page;
import com.adams.dcxt.dao.OrderDishesDao;

@Service("orderDishesService")
@Transactional
public class OrderDishesServiceImpl  implements  OrderDishesService {
    
    @Autowired
    private  OrderDishesDao orderDishesDao;
    @Override
    public Page<OrderDishes>  getListByOrderId(Long orderId ,Page<OrderDishes> page) {
        String hql  =" from OrderDishes where orderId = ? " ;
        return orderDishesDao.queryPage(page, hql, orderId);
    }
    @Override
    public void save(OrderDishes odishes) {
        orderDishesDao.save(odishes);
    }
    @Override
    public int queryCountDishesByTable(String orderId, String dishesId) {
        String hql =" from  OrderDishes od  where od.dishes.dishesId="+dishesId+"  and od.orderId="+orderId;
        return orderDishesDao.countHqlResult(hql, new HashMap());
    }
    @Override
    public void updateOrderDishes(String orderId, String dishesId,int counts) {
        String sql = "update dcxt_order_dishes set count=count+"+counts+" where  dishes_id="+dishesId+" and order_id="+orderId;
        orderDishesDao.executeSql(sql);
    }
	@Override
	public void updateGuoqi(int orderId) {
		//String sql = "update dcxt_order_dishes set checkstatus= "+Contants.ORDER_DISHES_BEFORE +" where order_id="+orderId +" and checkstatus = "+Contants.ORDER_DISHES_CHECK;
		//orderDishesDao.executeSql(sql);
	}
    
    
   
}
